function topListCtrl($scope, $http, paFetchService, ngDialog) {
  'ngInject';
  this.queryData = {}; // 查询条件对象 

  // 分页
  this.paginationData = {
    pageNum: 1,
    pageSize: 10,
    total: '',
  }

  // 页面调用方法
  $scope.pageChange = () => {
    $http.post(`${SERVER_CONTEXT}/api/redBlack/redBlackList/selectByUserCondition`,
        angular.extend(this.queryData, this.paginationData)
      )
      .then((resp) => {
        this.topList = resp.data.data;
        this.paginationData.total = resp.data.total;
      });
  };

  // 分页查询方法
  this.bangQuery = () => {
    $http.post(`${SERVER_CONTEXT}/api/redBlack/redBlackList/selectByUserCondition`,
        angular.extend(this.queryData, this.paginationData)
      )
      .then((resp) => {
        this.topList = resp.data.data;
        this.paginationData.total = resp.data.total;
      });
  }

  // 查询
  this.query = (param) => {
    if (param.endTime.$viewValue && param.startTime.$viewValue) {
      if (param.startTime.$viewValue < param.endTime.$viewValue) {
        this.bangQuery();
      } else {
        layer.alert('开始时间应小于结束时间');
      }
    } else {
      this.bangQuery();
    }
  };

  // 重置
  this.reset = () => {
    this.queryData = {};
  };

  // 删除红黑榜列表数据
  this.delete = (id) => {
    $scope.modalTitle = '删除红黑榜';
    $scope.modalContent = '确认要删除该信息吗?';
    ngDialog.openConfirm({
      template: 'paConfirm',
      className: 'ngdialog-theme-default pa-confirm-theme',
      scope: $scope,
    }).
    then((value) => {
      $http.delete(`${SERVER_CONTEXT}/api/redBlack/redBlackList/delete/${id}`).
      then((resp) => {
        if (resp.data.success) {
          layer.msg(resp.data.message);
          this.bangQuery();
        } else {
          layer.alert(resp.data.message);
        }
      });
    }, (reason) => {});
  }

  // 初始化页面
  this.initPage = () => {
    // 获得施工队list             
    paFetchService
      .getTeamWithOrgList()
      .then((resp) => {
        this.teamWithOrgList = resp.data;
      });
    // 获得标段list             
    paFetchService
      .getSectionList()
      .then((resp) => {
        this.sectionList = resp.data;
      });
    // 获取列表数据
    this.bangQuery();
  }

  this.initPage();
}

export default topListCtrl;